<template>
  <div>
    <nav-bar :title="pageData.attribute.title" />
    <low-code-page
      ref="lpgs"
      hide-navbar
      v-if="pageData"
      :pageJson="pageData"
    />
  </div>
</template>

<script>
import { getPageJson } from "@/service/api/sp-common/widget";
export default {
  name: "index",
  data() {
    return {
      pageData: null,
    };
  },

  onLoad(options) {
    console.log("onLoad");
    uni.showLoading({
      title: "加载中",
    });
    this.options = options;
    this.$nextTick(() => {
      this.initLowCodePage();
    });
  },
  methods: {
    initLowCodePage() {
      const { pageId } = this.options;
      if (pageId) {
        getPageJson({ id: pageId }).then((res) => {
          if (res) {
            uni.hideLoading();
            this.pageData = JSON.parse(res.pageJson);
          }
          console.log("页面配置", this.pageData);
        });
      }
    },
  },
};
</script>

<style scoped lang="scss"></style>
